﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Win32;
using Newtonsoft.Json;
using ReadJson.Models;
using ReadJson.Views;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace ReadJson.ViewModels
{
    public partial class MainViewModel : INotifyPropertyChanged
    {
        private object _currentPage;
        public object CurrentPage
        {
            get { return _currentPage;}
            set {
                _currentPage = value;
                OnPropertyChanged(nameof(CurrentPage));
            }

        }

        public ICommand NavigateToConfigCommand { get; }
        public ICommand NavigateToAboutCommand { get; }


        public MainViewModel()
        {       
            NavigateToConfigCommand = new RelayCommand(NavigateToConfig);
            NavigateToAboutCommand = new RelayCommand(NavigateToAbout);       
            NavigateToConfig();
        }

        private void NavigateToConfig()
        {           
            CurrentPage = new ConfigView();
        }

        private void NavigateToAbout()
        {            
            CurrentPage = new TextBlock
            {
                Text = "PLC配置管理系统 v1.0",
                FontSize = 24,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }


    }
}
